package com.example.yeujian5.yuejian5.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.yeujian5.yuejian5.R;
import com.example.yeujian5.yuejian5.bean.QuestionBean;

import java.util.List;

/**
 * Created by wangmengmeng on 2017/11/2.
 */

public class QuestionAdapter extends RecyclerView.Adapter{

    private List<QuestionBean> list;
    private Context context;

    public QuestionAdapter(List<QuestionBean> list,Context context)
    {
        this.context=context;
        this.list=list;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view= LayoutInflater.from(context).inflate(R.layout.cardview_question,viewGroup,false);
        AskViewHolder askViewHolder=new AskViewHolder(view);
        return askViewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
        AskViewHolder askViewHolder= (AskViewHolder) viewHolder;
        QuestionBean info=list.get(i);
        askViewHolder.askman.setText("提问用户:"+info.getUser_id());
        askViewHolder.askInfo.setText("   "+info.getQuestion());
        askViewHolder.anman.setText("回复大师:"+info.getMaster_id());
        askViewHolder.anInfo.setText("   "+info.getAnswer());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    public class AskViewHolder extends RecyclerView.ViewHolder{
        private TextView askman,askInfo,anman,anInfo;
        public AskViewHolder(View itemView) {
            super(itemView);
            askman=(TextView)itemView.findViewById(R.id.askman);
            askInfo=(TextView)itemView.findViewById(R.id.askInfo);
            anman=(TextView)itemView.findViewById(R.id.anman);
            anInfo=(TextView)itemView.findViewById(R.id.anInfo);
        }
    }
}
